<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="model.*"%>
<%@page import="model.sets.*"%>
<%@page import="db.DAOFactory"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Scene-map</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="/travelProject/resources/styles.css">
  </head>
  
  <body>
  	<% request.setCharacterEncoding("utf-8"); %>
    <div id="info">
		<input type="text" value="输入你要查询的关键字"/><input type="button" value="搜索景点"/>

	<%
		out.print("<p>Activity------------------------<p>");
		ArrayList<Activity> list=null;
		Activity object=null;	
		
		object = DAOFactory.getActivityDAO().findById(1);
		if(object!=null)
			out.print("<p>object:"+object.getName()+"<p>");
		list=DAOFactory.getActivityDAO().findByKeyword("打鬼子","描");
		if(!list.isEmpty())
			for(Iterator i=list.iterator();i.hasNext();){
				out.print("<p>list:"+((Activity)i.next()).getName()+"<p>");
			}
		
		list=DAOFactory.getActivityDAO().findAll();
		for(Iterator i=list.iterator();i.hasNext();){
			out.print("<p>list all:"+((Activity)i.next()).getName()+"<p>");
		}
		
		Activity object2=new Activity();
		object2.setName("打鬼子活动1");
		object2.setDescription("不要再错了");
		object2.setOwnerId(1);
		object2.setCreateDate(new Date());
		object2.setSightId(1);
		Spot point=DAOFactory.getSpotDAO().findById(9);
		out.print("<p>point9:"+point.getName()+"<p>");
		System.out.println(point.getName());
		object2.addSpot(point); 
		//DAOFactory.getActivityDAO().save(object2);
		object = DAOFactory.getActivityDAO().findByName("修改后的名字");
		out.print("<p>save select:"+object.getName()+"<p>");
		
		object = DAOFactory.getActivityDAO().findByName("哈哈4"); 
		ArrayList<Spot> pointList=object.getSpots();
		for(Iterator i=pointList.iterator();i.hasNext();){
			out.print("<p>list point:"+((Spot)i.next()).getName()+"<p>");
		}
		object.setName("哈哈4");
		DAOFactory.getActivityDAO().update(object);
		object = DAOFactory.getActivityDAO().findByName("哈哈4");
		out.print("<p>update name:"+object.getName()+"<p>");
		
		DAOFactory.getActivityDAO().delete(2);	
		object = DAOFactory.getActivityDAO().findById(2);
		if(object!=null)	
			out.print("<p>delete select:"+object.getName()+"<p>");
		else
			out.print("<p>delete select:null<p>");
		
		%>
    </div>
  </body>
</html>
